package com.scorpio.scbasics.into.mapper;

import com.scorpio.scbasics.rediostation.dto.BizJpushDTO;
import com.scorpio.scbasics.rediostation.dto.BizUserChannelDTO;
import com.scorpio.scbasics.rediostation.dto.BizUserDeviceDTO;
import org.apache.ibatis.annotations.*;

/**
 * 【请填写功能名称】Mapper接口
 *
 * @author scorpio
 * @date 2020-10-19
 */
@Mapper
public interface InitMapper {

    @Insert("insert into biz_user_device \n" +
            "                               (\n" +
            "\t\t                            user_id\n" +
            "                                   ,imei\n" +
            "                                   ,os\n" +
            "                                   ,version\n" +
            "                                   ,version_code\n" +
            "                                   ,vendor\n" +
            "                                   ,system_version\n" +
            "                                   ,system_model\n" +
            "                                   ,device_brand\n" +
            "                                   ,create_time\n" +
            "\t\t                       )\n" +
            "                            values\n" +
            "                                (\n" +
            "\t\t                            #{bud.user_id}\n" +
            "                                   ,#{bud.imei}\n" +
            "                                   ,#{bud.os}\n" +
            "                                   ,#{bud.version}\n" +
            "                                   ,#{bud.version_code}\n" +
            "                                   ,#{bud.vendor}\n" +
            "                                   ,#{bud.system_version}\n" +
            "                                   ,#{bud.system_model}\n" +
            "                                   ,#{bud.device_brand}\n" +
            "                                   ,default\n" +
            "\t\t                       )")
    int AddUserDevice(@Param("bud") BizUserDeviceDTO bud);


    @Insert("insert into biz_user_channel \n" +
            "                               (\n" +
            "\t\t                            user_id\n" +
            "                                   ,channel_code\n" +
            "                                   ,create_time\n" +
            "\t\t                       )\n" +
            "                            values\n" +
            "                                (\n" +
            "\t\t                            #{user_id}\n" +
            "\t\t                           ,#{channel_code}\n" +
            "                                   ,#{create_time}\n" +
            "\t\t                       )")
    int AddChannelCode(@Param("user_id")int user_id,@Param("channel_code")String channel_code,@Param("create_time")String create_time);


    @Update("update biz_user_channel set channel_code=#{channel_code} where user_id=#{user_id}")
    int ModifyChannelCode(@Param("user_id")int user_id, @Param("channel_code")String channel_code);


    @Select("select count(1) from biz_user_channel where user_id=#{user_id}")
    int ExistChannelCode(@Param("user_id")int user_id);

    @Select("select * from biz_user_channel where user_id=#{user_id}")
    BizUserChannelDTO GetChannelCodeByID(@Param("user_id")int user_id);


    @Insert("insert into biz_jpush \n" +
            "                               (\n" +
            "\t\t                            user_id\n" +
            "                                   ,registration_id\n" +
            "                                   ,ios_release_push\n" +
            "                                   ,create_time\n" +
            "\t\t                       )\n" +
            "                            values\n" +
            "                                (\n" +
            "\t\t                            #{user_id}\n" +
            "\t\t                           ,#{registration_id}\n" +
            "\t\t                           ,#{ios_release_push}\n" +
            "                                   ,default\n" +
            "\t\t                       )")
    int AddJPush(@Param("user_id")int user_id, @Param("registration_id")String registration_id,@Param("ios_release_push")String ios_release_push);


    @Update("update biz_jpush set registration_id=#{registration_id},ios_release_push=#{ios_release_push} where user_id=#{user_id}")
    int ModifyJPush(@Param("user_id")int user_id, @Param("registration_id")String registration_id,@Param("ios_release_push")String ios_release_push);


    @Delete("delete from biz_jpush where user_id=#{user_id}")
    int RemoveJPush(@Param("user_id")int user_id);

    @Select("select * from biz_jpush where user_id=#{user_id}")
    BizJpushDTO GetRegistrationID(@Param("user_id")int user_id);
}
